package com.zb.select.controller;

import com.zb.entity.SelectVo;
import com.zb.result.Result;
import com.zb.service.ZjCodeBatchGoodsService;
import com.zb.service.ZjCodeBatchService;
import com.zb.service.ZjCodePrintTemplateService;
import com.zb.service.ZjCodeService;
import com.zb.utils.TokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author WEN
 * @Date 2023/9/7 0007
 **/
@Api(tags = "编码下拉类接口")
@RestController
@RequestMapping("/code/select")
public class CodeSelectController {
    @Resource
    private ZjCodeBatchService codeBatchService;
    @Resource
    private ZjCodeBatchGoodsService codeBatchGoodsService;
    @Resource
    private ZjCodePrintTemplateService codePrintTemplateService;

    @ApiOperation("批次编码下拉列表查询")
    @PostMapping("/codeBatchPageSelect")
    public Result codeBatchPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success().data(codeBatchService.codeBatchPageSelect(custAccId, selectVo));
    }

    @ApiOperation("根据批次编码ID获取批次编码商品数据列表")
    @PostMapping("/codeBatchGoodsPageSelect/{batchId}")
    public Result codeBatchGoodsPageSelect(HttpServletRequest request, @PathVariable @ApiParam(value = "批次编码ID", required = true) Long batchId,
                                           @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success().data(codeBatchGoodsService.codeBatchGoodsPageSelect(custAccId, batchId, selectVo));
    }

    @ApiOperation("打印模板下拉列表查询")
    @PostMapping("/codePrintTemplatePageSelect")
    public Result codePrintTemplatePageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success().data(codePrintTemplateService.codePrintTemplatePageSelect(custAccId, selectVo));
    }


}
